package com.bosssoft.cloud.wechat.core.bean.msg.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.bosssoft.cloud.wechat.core.bean.WxBaseMsg;
import com.bosssoft.cloud.wechat.core.bean.msg.Articles;
import com.bosssoft.cloud.wechat.infrastructure.constant.WxKeywordConsts;
import com.bosssoft.cloud.wechat.infrastructure.annotation.XmlRoot;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.List;

/**
 * 回复图文消息
 *
 * @author wcy create on 2021/5/27 17:04 下午
 */
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@XmlRoot
public class ArticlesVO extends WxBaseMsg {
    /**
     * 图文消息个数；当用户发送文本、图片、语音、视频、图文、地理位置这六种消息时，开发者只能回复1条图文消息；其余场景最多可回复8条图文消息
     */
    @JSONField(name = "ArticleCount")
    private String articleCount;
    /**
     * 图文消息信息，注意，如果图文数超过限制，则将只发限制内的条数
     */
//    @JacksonXmlElementWrapper(localName = "Articles")
    @JSONField(name = "Articles")
    private Articles articles;

    public ArticlesVO(String toUserName, String fromUserName, String articleCount, List<Articles.Item> items) {
        super(toUserName, fromUserName, String.valueOf(System.currentTimeMillis() / 1000), WxKeywordConsts.MsgType.NEWS);
        this.articleCount = articleCount;
        this.articles = new Articles(items);
    }
}
